package com.example.myservlet;

import com.example.anno.RequestMapping;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@RequestMapping("/query")
public class QueryParamServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        String name = req.getParameter("name");
        int age = Integer.parseInt(req.getParameter("age"));   // 简单转换
        resp.setContentType("text/plain;charset=UTF-8");
        resp.getWriter().printf("name=%s, age=%d%n", name, age);
    }
}